import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg';

export default (appInfo: EggAppInfo) => {
  const config = {} as PowerPartial<EggAppConfig>;

  // override config from framework / plugin
  // use for cookie sign key, should change to your own and keep security
  config.keys = `${appInfo.name}_1627383618865_2767`;

  // 如果需要加载静态资源，请启用 spa 中间件
  config.middleware = ['resultWrapper'/* , 'spa' */];

  // config.sequelize = {
  // dialect: 'mysql',
  // host: '127.0.0.1',
  // port: 3306,
  // database: 'database_test',
  // username: 'database_test',
  // password: "",
  // define: {
  //   freezeTableName: true,
  //   timestamps: true,
  //   createdAt: true,
  //   updatedAt: true,
  //   underscored: true,
  // },
  // };

  // add your special config in here
  const bizConfig = {
    sourceUrl: `https://github.com/eggjs/examples/tree/master/${appInfo.name}`,
  };

  config.multipart = {
    mode: 'file',
    whitelist: () => true,
  };

  config.security = {
    csrf: {
      enable: false,
    },
    xframe: {
      enable: false,
    },
  };

  // the return config will combines to EggAppConfig
  return {
    ...config,
    ...bizConfig,
  };
};
